#ifndef __controls_H
#define __controls_H

#include <p24FJ32GA002.h>
#include <stdio.h>

#define _BV(bit) (1 << (bit))
#define bit_is_set(register,bit) (register & (1 << (bit)))
#define bit_is_clear(register,bit) (!(register & (1 << (bit)))) 

unsigned char lastcontrols; //bit0 = more then 1 button pressed
							//bit1 = UP button pressed
							//bit2 = DOWN button pressed
							//bit3 = LEFT button pressed
							//bit4 = RIGHT button pressed

#define DPAD_UP_TRIS 	TRISBbits.TRISB9
#define DPAD_UP 		LATBbits.LATB9
#define DPAD_DOWN_TRIS 	TRISBbits.TRISB7
#define DPAD_DOWN 		LATBbits.LATB7
#define DPAD_LEFT_TRIS 	TRISBbits.TRISB6
#define DPAD_LEFT 		LATBbits.LATB6
#define DPAD_RIGHT_TRIS TRISBbits.TRISB8
#define DPAD_RIGHT 		LATBbits.LATB8	


void ButtonChanged(void);
unsigned char GetButtons(void);
void InitControls(void);

#endif
